#include <iostream>
#include <vector>
#include "geometry.h"

int main()
{
   polygon pol = polygon();
   
   int m;
   std::cin >> m;
   std::vector<polygon> holes;
   for (int i = 0; i < m; i++)
   {
      holes.push_back(polygon());
   }

   int l;
   std::cin >> l;
   for (int i = 0; i < l; i++)
   {
      double x, y;
      std::cin >> x >> y;
      point p = point(x, y);
      int is_in_polygon = pol.in_polygon(p);
      if (is_in_polygon != 1)
      {
         std::cout << is_in_polygon << "\n";
         continue;
      }

      bool in_hole = false;
      for (int j = 0; j < m; j++)
      {
         is_in_polygon = holes[j].in_polygon(p);
         if (is_in_polygon != -1)
         {
                std::cout << (-is_in_polygon) << "\n";
                in_hole = true;
                continue;
         }
      }

      if (!in_hole)
      {
         std::cout << 1 << "\n";
      }
   }
   return 0;
}